export default {
  namespaced: true,
  state: {
    allRoles: [],
    currentSecondTabs: [],
    currentThirdTabs: []
  },
  getters: {
    currentRole (state, getters, rootState) {
      return state.allRoles.find(role => {
        return role.roleID === rootState.user.currentUser.userCurrentRoleID;
      });
    },
    currentRolePermission (state, getters) {
      if (getters.currentRole) {
        return JSON.parse(getters.currentRole.values);
      }
      return {};
    },
    mainTabs (state, getters) {
      return getters.currentRolePermission.children;
    }
  },
  mutations: {
    setAllRoles (state, roles) {
      state.allRoles = roles;
    },
    setCurrentSecondTabs (state, tabs) {
      state.currentSecondTabs = tabs;
    },
    setCurrentThirdTabs (state, tabs) {
      state.currentThirdTabs = tabs;
    }
  },
  actions: {}
};
